package com.smart.village.big.screen.controller.bigscreen;

import com.smart.village.big.screen.domain.AjaxResult;
import com.smart.village.big.screen.service.AgricultureService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

/**
 * 数智农业数据接口
 */
@Tag(name = "数智农业数据接口")
@RestController
@RequestMapping("/agriculture")
public class AgricultureController {
    @Autowired
    private AgricultureService agricultureService;

    /**
     * 数智农业 根据 村镇 获取自然资源坐标列表 渲染地图
     *
     * @return
     */
    @Operation(summary = "数智农业 根据 村镇 获取自然资源坐标列表 渲染地图")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传"),
            @Parameter(name = "naturalResourceUsageSerialNumber", description = "自热资源用途编码 非必传"),
            @Parameter(name = "naturalResourceTypeSerialNumber", description = "自然资源类型 非必传"),
            @Parameter(name = "policyTypeSerialNumber", description = "补贴类型 非必传"),
            @Parameter(name = "cropCategorySerialNumber", description = "作物类型 非必传"),
            @Parameter(name = "monitoringEquipmentSerialNumber", description = "设备 非必传"),
    })
    @GetMapping("/getNaturalResourcesCoords")
    @ResponseBody
    public AjaxResult getNaturalResourcesCoords(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false) String naturalResourceUsageSerialNumber,
            @RequestParam(required = false) String naturalResourceTypeSerialNumber,
            @RequestParam(required = false) String policyTypeSerialNumber,
            @RequestParam(required = false) String cropCategorySerialNumber,
            @RequestParam(required = false) String monitoringEquipmentSerialNumber
    ) {
        return AjaxResult.success(agricultureService.getNaturalResourcesCoords(townNumber,
                villageNumber,
                naturalResourceUsageSerialNumber,
                naturalResourceTypeSerialNumber,
                policyTypeSerialNumber,
                cropCategorySerialNumber,
                monitoringEquipmentSerialNumber));
    }

    /**
     * 数智农业 根据 村镇、获取确权坐标列表
     *
     * @return
     */
    @Operation(summary = "数智农业 根据 村镇、获取确权坐标列表")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传"),
    })
    @GetMapping("/getNaturalResourcesConfirmationRights")
    @ResponseBody
    public AjaxResult getNaturalResourcesConfirmationRights(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber
    ) {
        return AjaxResult.success(agricultureService.getNaturalResourcesConfirmationRights(townNumber, villageNumber));
    }

    /**
     * 数智农业 产业结构
     *
     * @return
     */
    @Operation(summary = "数智农业 产业结构 ")
    @Parameters({
            @Parameter(name = "year", description = "年份 必传默认当前年"),
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传")
    })
    @GetMapping("/getIndustrialStructureStatics")
    @ResponseBody
    public AjaxResult getIndustrialStructureStatics(
            @RequestParam String year,
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber
    ) {
        return AjaxResult.success(agricultureService.getIndustrialStructureStatics(year, townNumber, villageNumber));
    }

    /**
     * 数智农业 补贴信息
     *
     * @return
     */
    @Operation(summary = "数智农业 补贴信息 ")
    @Parameters({
            @Parameter(name = "year", description = "年份 必传默认当前年"),
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传")
    })
    @GetMapping("/getSubsidyInformation")
    @ResponseBody
    public AjaxResult getSubsidyInformation(
            @RequestParam String year,
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber
    ) {
        return AjaxResult.success(agricultureService.getSubsidyInformation(year, townNumber, villageNumber));
    }

    /**
     * 数智农业 补贴信息
     *
     * @return
     */
    @Operation(summary = "数智农业 政策宣传 ")
    @GetMapping("/getPolicyAdvocacy")
    @ResponseBody
    public AjaxResult getPolicyAdvocacy(
            @RequestParam(required = false, defaultValue = "1") @Parameter(description = "当前页数") int pageNum,
            @RequestParam(required = false, defaultValue = "10") @Parameter(description = "每页条数") int pageSize,
            @RequestParam @Parameter(description = "终端类型") String NewsTerminal
    ) {
        if (ObjectUtils.isEmpty(pageNum) || pageNum == 0) {
            pageNum = 1;
        }
        if (ObjectUtils.isEmpty(pageSize) || pageSize == 0) {
            pageSize = 10;
        }
        return AjaxResult.success(agricultureService.getPolicyAdvocacy(pageNum, pageSize,NewsTerminal));
    }

    /**
     * 数智农业 项目信息
     *
     * @return
     */
    @Operation(summary = "数智农业 项目信息 ")
    @GetMapping("/getProjectInformation")
    @ResponseBody
    public AjaxResult getProjectInformation(
            @RequestParam String year,
            @RequestParam(required = false) String townNumber,
            @RequestParam String villageNumber
    ) {

        return AjaxResult.success(agricultureService.getProjectInformation(year, townNumber, villageNumber));
    }

    /**
     * 数智农业 地图 补贴下拉
     *
     * @return
     */
    @Operation(summary = "数智农业 地图 补贴下拉 ")
    @GetMapping("/getSubsidyPolicyType")
    @ResponseBody
    public AjaxResult getSubsidyPolicyType(
    ) {

        return AjaxResult.success(agricultureService.getSubsidyPolicyType());
    }

    /**
     * 数智农业 地图 作物下拉
     *
     * @return
     */
    @Operation(summary = "数智农业 地图 作物下拉 ")
    @GetMapping("/getCropCategory")
    @ResponseBody
    public AjaxResult getCropCategory(
    ) {

        return AjaxResult.success(agricultureService.getCropCategory());
    }

    /**
     * 数智农业 地图 作物下拉
     *
     * @return
     */
    @Operation(summary = "数智农业 地图 设备大类下拉 ")
    @GetMapping("/getMonitorDeviceCategory")
    @ResponseBody
    public AjaxResult getMonitorDeviceCategory(
    ) {

        return AjaxResult.success(agricultureService.getMonitorDeviceCategory());
    }

    /**
     * 数智农业 地图 集体资源用地图例
     *
     * @return
     */
    @Operation(summary = "数智农业 地图 集体资源用地图例 ")
    @GetMapping("/getResourceUsageList")
    @ResponseBody
    public AjaxResult getResourceUsageList(
    ) {

        return AjaxResult.success(agricultureService.getResourceUsageList());
    }

    /**
     * 数智农业 三资公开 三个指标和列表
     *
     * @return
     */
    @Operation(summary = "数智农业 三资公开 三个指标和列表 ")
    @GetMapping("/getThreeResourceDisclosureInformation")
    @ResponseBody
    public AjaxResult getThreeResourceDisclosureInformation(
            @RequestParam String NewsTerminal,
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false, defaultValue = "1") @Parameter(description = "当前页数") int pageNum,
            @RequestParam(required = false, defaultValue = "10") @Parameter(description = "每页条数") int pageSize
    ) {

        return AjaxResult.success(agricultureService.getThreeResourceDisclosureInformation(NewsTerminal,townNumber, villageNumber, pageNum, pageSize));
    }

    /**
     * 数智农业 基础数据 视频监控
     *
     * @return
     */
    @Operation(summary = "数智农业 基础数据 视频监控 ")
    @GetMapping("/getMonitorDeviceList")
    @ResponseBody
    public AjaxResult getMonitorDeviceList(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false, defaultValue = "1") @Parameter(description = "当前页数") int pageNum,
            @RequestParam(required = false, defaultValue = "10") @Parameter(description = "每页条数") int pageSize
    ) {

        return AjaxResult.success(agricultureService.getMonitorDeviceList(townNumber, villageNumber, pageNum, pageSize));
    }
}
